#include "TaskLauncher.h"

#include <stdexcept>

TaskLauncher::TaskLauncher(size_t thread_count) :
                           pool_(thread_count) { 
    validate(thread_count);
}

std::future<TaskLauncher::ResultType>
TaskLauncher::launch(std::function<ResultType(void)> f) {

    return pool_.enqueue(f);
}

void TaskLauncher::validate(size_t thread_count) const {

    if (thread_count == 0) {
        throw std::invalid_argument("Threads number must be not zero.");
    }
}
